import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/widgets.dart'hide Action;
import 'package:school_safe_teacher/constans/route_constants.dart';

import 'action.dart';
import 'state.dart';

import 'package:rammus/rammus.dart' as rammus;

Effect<IndexState> buildEffect() {
  return combineEffects(<Object, Effect<IndexState>>{
    // IndexAction.action: _onAction,
    Lifecycle.initState: _init,
  });
}

void _init(Action action, Context<IndexState> ctx) {
  rammus.onNotification.listen((data) {
    print("----------->notification here ${data.summary}");
  });
  rammus.onNotificationOpened.listen((data) {
    print("-----------> ${data.summary} 被点了");
    // Map<String, dynamic> user = jsonDecode(data.extras);
    Navigator.of(ctx.context)
        .pushNamed(RouteConstants.MESSAGE);
  });

  rammus.onNotificationRemoved.listen((data) {
    print("-----------> $data 被删除了");
  });

  rammus.onNotificationReceivedInApp.listen((data) {
    print("-----------> ${data.summary} In app");
  });

  rammus.onNotificationClickedWithNoAction.listen((data) {
    print("${data.summary} no action");
  });
  rammus.onMessageArrived.listen((data) {
    print("received data -> ${data.content}");
  });
}
